home *** CD-ROM | disk | FTP | other *** search
- head 1.6;
- access;
- symbols;
- locks
- dennisg:1.6; strict;
- comment @ * @;
-
-
- 1.6
- date 92.01.03.02.55.03; author dennisg; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 91.12.10.12.05.28; author dennisg; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 91.12.03.02.01.23; author dennisg; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 91.11.24.14.48.02; author dennisg; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 91.11.24.01.20.02; author dennisg; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 91.11.23.22.20.42; author dennisg; state Exp;
- branches;
- next ;
-
-
- desc
- @this file holds some functions from hash.c that have been
- converted to inlines.
- @
-
-
- 1.6
- log
- @modified to handle new initialization scheme.
- fixed code structure.
- @
- text
- @/* -*-c-*-
- * This file contains certain functions of
- * the hashing algorithm that are inline.
- * These functions are used in critical regions
- * of the run-time where inlining can improve
- * performance.
- *
- * Copyright (C) 1991 Threaded Technologies Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 1, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should receive a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash-inline.h,v 1.5 1991/12/10 12:05:28 dennisg Exp dennisg $
- $Author: dennisg $
- $Date: 1991/12/10 12:05:28 $
- $Log: hash-inline.h,v $
- * Revision 1.5 1991/12/10 12:05:28 dennisg
- * Cleaned up file format for a distribution.
- *
- * Revision 1.4 1991/12/03 02:01:23 dennisg
- * fixed assert macro.
- * added memory allocation adjustment macro for hash size allocation.
- *
- * Revision 1.3 1991/11/24 14:48:02 dennisg
- * modified hash_value_for_key () to remove two variables.
- * "indx" was initialized with a value from a function then used only once.
- * the information used in "found" can be terermined from "retVal".
- *
- * Revision 1.2 1991/11/24 01:20:02 dennisg
- * changed shorts back to ints.
- * the efficiency gained didn't out weight the grossness of the code.
- *
- * Revision 1.1 1991/11/23 22:20:42 dennisg
- * Initial revision
- *
- */
-
- #ifndef _hash_inline_INCLUDE_GNU
- #define _hash_inline_INCLUDE_GNU
-
- /* If someone is using a c++
- compiler then adjust the
- types in the file back
- to C. */
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #include <assert.h>
- #include <hash.h>
- #include <ObjC.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include <sys/types.h>
-
-
- /* Function that is private
- to the hashing code. It
- returns a hash table index
- calculated from a key. */
- static inline u_int hashIndex(Cache_t theCache, void* aKey) {
-
-
- assert(sizeof (u_int) == sizeof (aKey));
-
- return ((u_int)aKey) % theCache->sizeOfHash;
- }
-
-
- /* Given key, return its
- value. Return NULL if the
- key/value pair isn't in
- the hash. */
- static inline void* hash_value_for_key (Cache_t theCache, void* aKey) {
-
- CacheNode_t aCacheNode =
- (*theCache->theNodeTable)[ hashIndex(theCache, aKey) ];
- void* retVal = NULL;
-
-
- if (aCacheNode)
- do {
- if (aCacheNode->theKey == aKey)
- retVal = aCacheNode->theValue;
- else
- aCacheNode = aCacheNode->nextNode;
- } while (!retVal && aCacheNode);
-
- return retVal;
- }
-
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
- @
-
-
- 1.5
- log
- @Cleaned up file format for a distribution.
- @
- text
- @d23 1
- a23 1
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash-inline.h,v 1.4 1991/12/03 02:01:23 dennisg Exp dennisg $
- d25 1
- a25 1
- $Date: 1991/12/03 02:01:23 $
- d27 3
- a60 1
- #include <libc.h>
- d62 2
- @
-
-
- 1.4
- log
- @fixed assert macro.
- added memory allocation adjustment macro for hash size allocation.
- @
- text
- @d3 1
- a3 1
- * the hashing algorithm that are inline.
- d5 2
- a6 2
- * of the run-time where inlining can improve
- * performance.
- d23 1
- a23 1
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash-inline.h,v 1.3 1991/11/24 14:48:02 dennisg Exp dennisg $
- d25 1
- a25 1
- $Date: 1991/11/24 14:48:02 $
- d27 4
- d56 4
- a59 4
- #include <assert.h>
- #include <hash.h>
- #include <libc.h>
- #include <ObjC.h>
- d63 4
- a66 4
- /* Function that is private
- to the hashing code. It
- returns a hash table index
- calculated from a key. */
- d70 1
- a70 1
- assert(sizeof (u_int) == sizeof (aKey));
- d72 1
- a72 1
- return ((u_int)aKey) % theCache->sizeOfHash;
- d83 1
- a83 1
- (*theCache->theNodeTable)[ hashIndex(theCache, aKey) ];
- @
-
-
- 1.3
- log
- @modified hash_value_for_key() to remove two variables.
- "indx" was initialized with a value from a function then used only once.
- the information used in "found" can be terermined from "retVal".
- @
- text
- @d23 1
- a23 1
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash-inline.h,v 1.2 1991/11/24 01:20:02 dennisg Exp dennisg $
- d25 1
- a25 1
- $Date: 1991/11/24 01:20:02 $
- d27 5
- d63 1
- a63 1
- static inline u_int hashIndex (Cache_t theCache, void* aKey) {
- d66 3
- a68 3
- assert (sizeof (u_int) == sizeof (aKey));
-
- return (u_int)aKey % theCache->sizeOfHash ;
- d79 1
- a79 1
- (*theCache->theNodeTable)[ hashIndex (theCache, aKey) ];
- @
-
-
- 1.2
- log
- @changed shorts back to ints.
- the efficiency gained didn't out weight the grossness of the code.
- @
- text
- @d23 1
- a23 1
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash-inline.h,v 1.1 1991/11/23 22:20:42 dennisg Exp dennisg $
- d25 1
- a25 1
- $Date: 1991/11/23 22:20:42 $
- d27 4
- d58 1
- a58 1
- static inline u_int hashIndex( Cache_t theCache, void* aKey ) {
- d71 1
- a71 1
- static inline void* hash_value_for_key( Cache_t theCache, void* aKey ) {
- d73 2
- a74 2
- u_int indx = hashIndex( theCache, aKey );
- CacheNode_t aCacheNode = ( *theCache->theNodeTable )[ indx ];
- d78 1
- a78 3
- if( aCacheNode ) {
- BOOL found = NO;
-
- d80 2
- a81 2
- if( aCacheNode->theKey == aKey )
- retVal = aCacheNode->theValue, found = YES;
- d84 1
- a84 2
- } while( !found && aCacheNode );
- }
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d23 1
- a23 1
- $Header: /usr/user/dennis_glatting/ObjC/c-runtime/lib/RCS/hash.c,v 0.6 1991/11/21 22:27:06 dennisg Exp dennisg $
- d25 5
- a29 2
- $Date: 1991/11/21 22:27:06 $
- $Log: hash.c,v $
- d54 1
- a54 1
- static inline u_short hashIndex( Cache_t theCache, void* aKey ) {
- d57 1
- a57 1
- assert ((2*sizeof (u_short)) == sizeof (aKey));
- d59 1
- a59 3
- return ((*((u_short(*)[])&aKey))[0] ^
- (*((u_short(*)[])&aKey))[1]) %
- (u_short)theCache->sizeOfHash ;
- d69 1
- a69 1
- u_short indx = hashIndex( theCache, aKey );
- @
-